/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "Creator.h"

namespace liba
{
namespace input
{
namespace hard
{
namespace macx
{

static Keyboard * keyboard;
static Mouse * mouse;
static Mouse * mouse2;

Creator::Creator()
{
	if( keyboard || mouse )
		THROW(Gluck(__FUNCTION__, "keyboard or mouse already exist"));
	keyboard = new Keyboard;
	mouse = new Mouse("Mouse");
	mouse2 = new Mouse("Mouse2");

//	RECT rect;
//	GetClientRect( get_window()->get_wnd(), &rect );
//	resize( rect.bottom - rect.top, rect.right - rect.left );
}

Creator::~Creator()
{
	delete mouse2; mouse2 = 0;
	delete mouse; mouse = 0;
	delete keyboard; keyboard = 0;
}

void Creator::mouse_up(int key, int mouse_num )
{
	if(mouse_num != 0)
	{
		if(mouse2)
			mouse2->mouse_up( key );
	}
	else
{
	if(mouse)
		mouse->mouse_up( key );
}
}
void Creator::mouse_move(int x, int y, int mouse_num)
{
	if(mouse_num != 0)
	{
		if(mouse2)
			mouse2->mouse_move( x, y );
	}
	else
{
	if(mouse)
		mouse->mouse_move( x, y );
}
}
void Creator::mouse_down(int key, int mouse_num )
{
	if(mouse_num != 0)
	{
		if(mouse2)
			mouse2->mouse_down( key );
	}
	else
{
	if(mouse)
		mouse->mouse_down( key );
}
}
void Creator::key_up(int scan_code)
{
	if(keyboard)
		keyboard->key_up( scan_code );
}
void Creator::key_down(int scan_code)
{
	if(keyboard)
		keyboard->key_down( scan_code );
}
void Creator::key_char(wchar_t letter)
{
	if(keyboard)
		keyboard->key_char( letter );
}

void Creator::resize(int height, int width)
{
	if(mouse)
		mouse->resize(height, width);
	if(mouse2)
		mouse2->resize(height, width);	
}

} // namespace macx
} // namespace hard
} // namespace input
} // namespace liba


